package com.bionet.keggservice.handler;

import com.bionet.keggservice.exception.BionetException;
import com.bionet.service_base.utils.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author hzx
 * @create 2021-09-27 15:45
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        return Result.error().message("error");
    }

    @ExceptionHandler(BionetException.class)
    @ResponseBody
    public Result error(BionetException e){
        return Result.error().message(e.getMsg()).code(e.getCode());
    }
}
